<?php

!defined('IN_HDWIKI') && exit('Access Denied');
 
class control extends base{

	function control(& $get,& $post){
		$this->base( & $get,& $post);
		$this->load('category');
	}

 	function dodefault() {
 		$all_category=$_ENV['category']->get_category_cache(); 
 		$categorylist=$_ENV['category']->get_site_category(0,$all_category);
		$indexcache=$this->cache->getcache('indexcache',$this->setting['index_cache_time']);
		if(!(bool)$indexcache){
			$this->load('doc');
			$recentupdatelist=$_ENV['doc']->get_list(1,0,$this->setting['index_recentupdate']);
			$commenddocs=$_ENV['doc']->get_focus_list(0,$this->setting['index_commend']);
			$fistcommenddoc=is_array($commenddocs)?array_shift($commenddocs):array();
			$this->load('user');
			$weekuserlist=$_ENV['user']->get_week_user(0,$this->setting['index_weekuser'], $this->time-60*60*24*7 );
			$topuserlist=$_ENV['user']->get_top_user(0,$this->setting['index_topuser']);
			@$hottag=unserialize($this->setting['hottag']);
			$hottag=is_array($hottag)?$hottag:array();
			$this->load('friendlink');
			$friendlinklist=$_ENV['friendlink']->get_link_list();
			$this->load('comment');
			$recentcommentlist=$_ENV['comment']->recent_comment(0,$this->setting['index_recentcomment']);
			$indexcache=array(
				'fistcommenddoc'=>$fistcommenddoc,
				'commenddocs'=>$commenddocs,
				'recentupdatelist'=>$recentupdatelist,
				'weekuserlist'=>$weekuserlist,
				'topuserlist'=>$topuserlist,
				'hottag'=>$hottag,
				'friendlink'=>$friendlinklist,
				'recentcommentlist'=>$recentcommentlist
				);
			$this->cache->writecache('indexcache',$indexcache);
		}
		$this->load('adv');
		$advlist=$_ENV['adv']->adv_index_filter($this->advertisement);
		if($advlist){
			$this->view->assign('advlist',$advlist);
		}
 		$this->view->assign('categorylist',$categorylist);
		$this->view->assign('indexcache',$indexcache);
		$this->view->display('index');
	}

 	function dosetstyle() {
		$this->hsetcookie('style',$this->get[2],24*3600*365);
		$this->header();
	}
}
?>